/*
//
//              INTEL CORPORATION PROPRIETARY INFORMATION
//  This software is supplied under the terms of a license  agreement or
//  nondisclosure agreement with Intel Corporation and may not be copied
//  or disclosed except in  accordance  with the terms of that agreement.
//    Copyright (c) 2007 Intel Corporation. All Rights Reserved.
//
//
*/

#ifndef __UMC_AVS_SEQUENCE_HEADER_H
#define __UMC_AVS_SEQUENCE_HEADER_H

#include "ippdefs.h"
#include "umc_structures.h"

namespace UMC
{

struct AVS_SEQUENCE_HEADER
{
    // sequence header ID
    Ipp32u video_sequence_start_code;

    // specifies the profile of a bitstream.
    Ipp32u profile_id;

    // specifies the level of a bitstream.
    Ipp32u level_id;

    // specifies the scan format in a sequence. '1' means there are only
    // progressive pictures in a sequence. '0' means the sequence may contain
    // progressive and interlaced pictures.
    Ipp32u progressive_sequence;

    // 14-bit unsigned integer. It specifies the display width of the luma
    // component, i.e. the number of samples in horizontal direction. Width
    // of display area calculated in MB unit is:
    //     MbWidth = (horizontal_size + 15) / 16
    // horizontal_size shall not be 0.
    Ipp32u horizontal_size;

    // 14-bit unsigned integer. It specifies the display height of
    // the luminance component, i.e. the number of samples in vertical
    // direction. In bitstream, when two fields of an interlaced picture appear
    // in alternate order, the height of display area in MB unit is:
    //     MbHeight = 2 x ((vertical_size + 31) / 32)
    // Otherwise, the height of display area in MB unit is:
    //     MbHeight = (vertical_size + 15) / 16
    // vertical_size shall not be 0.
    Ipp32u vertical_size;

    // specifies the chroma component format.
    Ipp32u chroma_format;

    // specifies the precision of luma and chroma samples. Shall be 1
    Ipp32u sample_precission;

    // specifies the sample aspect ratio (SAR) or display aspect
    // ratio (DAR) of reconstructed pictures.
    Ipp32u aspect_ratio;

    // specifies the frame rate.
    Ipp64f frame_rate;

    // low-order 18 bits of BitRate.
    Ipp32u bit_rate_lower;

    // high-order 12 bits of BitRate.
    //     BitRate = (bit_rate_upper << 18) + bit_rate_lower
    // BitRate is calculated in 400bits/s and it is a ceiling integer.
    // BitRate shall not be 0.
    Ipp32u bit_rate_upper;

    // '1' means that B-picture is not present in video sequence,
    // picture reordering delay is not present, and "big picture"
    // may be present in bitstream (See Annex D); '0' means that B-picture
    // can be present in video sequence, picture reordering delay may exist,
    // and "big picture" shall not present in bitstream.
    Ipp32u low_delay;

    // specifies the requirement for bitstream buffer size of
    // BBV for decoding (See Annex D). BBS is the minimum bitstream buffer size
    // in bits for video decoding, and it is calculated as:
    //     BBS = 16 X 1024 X bbv_buffer_size
    Ipp32u bbv_buffer_size;
};

// Decode sequence header
Status DecodeAVSSequenceHeader(AVS_SEQUENCE_HEADER *pSeqHeader,
                               const Ipp8u *pbSrc,
                               size_t srcSize);

// Decode sequence header
Status EncodeAVSSequenceHeader(Ipp8u **pbDst,
                               size_t dstSize,
                               const AVS_SEQUENCE_HEADER *pSeqHeader);

} // namespace UMC

#endif // __UMC_AVS_SEQUENCE_HEADER_H
